package com.xxx.service.impl;

import com.xxx.dao.OrderItemDao;
import com.xxx.pojo.OrderItem;
import com.xxx.service.OrderItemService;
import com.xxx.service.ex.InsertException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class OrderItemServiceImpl implements OrderItemService {
    @Autowired
    private OrderItemDao orderItemDao;

    //保存单个订单信息功能
    @Override
    public void saveOrderItem(OrderItem orderItem, String username) {
        orderItem.setCreatedUser(username);
        orderItem.setCreatedTime(new Date());
        orderItem.setModifiedUser(username);
        orderItem.setModifiedTime(new Date());
        int row = orderItemDao.insert(orderItem);
        if(row!=1){
            throw new InsertException("(保存单个订单数据时)插入数据时产生未知异常");
        }
    }
}
